﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace RefOffPDA
{
    /*
     * Class: Incident
     * 
     * Use: Form displaying the options for recording incidents
     *      during a match, namely Caution, Sending Off and
     *      Substitution
     *      
     * Author: Mike Skaife, mcs3@aber.ac.uk
     */      
    public partial class Incident : Form
    {
        //The current Match object
        private Match theMatch;

        //Indicates whether the home or away team is involved in the Incident
        private String homeOrAway;
        
        public Incident(Match theMatch, String homeAway)
        {
            InitializeComponent();
            this.theMatch = theMatch;
            this.homeOrAway = homeAway;
        }

        //This method is run if the 'Caution' button is clicked
        private void IncidentCautionBtn_Click(object sender, EventArgs e)
        {
            //This code runs if the incident relates to the home team
            if (homeOrAway.Equals("home"))
            {
                //Display the Caution screen and hide this screen
                theMatch.homeCaution.Visible = true;
                this.Visible = false;
            }
            //This code runs if the incident relates to the away team
            else
            {
                //Display the Caution screen and hide this screen
                theMatch.awayCaution.Visible = true;
                this.Visible = false;
            }
        }

        //This method is run if the 'Sending Off' button is clicked
        private void IncidentSendOffBtn_Click(object sender, EventArgs e)
        {
            //This code runs if the incident relates to the home team
            if (homeOrAway.Equals("home"))
            {
                //Display the Sending Off screen and hide this screen
                theMatch.homeSendOff.Visible = true;
                this.Visible = false;
            }
            //This code runs if the incident relates to the away team
            else
            {
                //Display the Sending Off screen and hide this screen
                theMatch.awaySendOff.Visible = true;
                this.Visible = false;
            }
        }

        //This method is run if the 'Substitution' button is clicked
        private void IncidentSubBtn_Click(object sender, EventArgs e)
        {
            //This code runs if the incident relates to the home team
            if (homeOrAway.Equals("home"))
            {
                //Display the Substitution screen and hide this screen
                theMatch.homeSubOff.Visible = true;
                this.Visible = false;
            }
            //This code runs if the incident relates to the away team
            else
            {
                //Display the Substitution screen and hide this screen
                theMatch.awaySubOff.Visible = true;
                this.Visible = false;
            }
        }

        //This method is run when the 'Cancel' button is clicked
        private void CancelButton_Click(object sender, EventArgs e)
        {
            //Hide this screen to display the main Match screen
            this.Visible = false;
        }
    }
}